#include "CommonDef.h"
#include <iostream>

void StringReplace(string & dst, string src, string subsrc, string subdst)
{
	dst = src;
	size_t found = dst.find(subsrc);
	while(found!=string::npos)
	{
		dst.replace(found, subsrc.length(), subdst);
		found = dst.find(subsrc, found+1);
	}
}

fileoff GetFileSize(string strFilename)
{
	FILE * stream;
	filepos pos;
	if( (stream = fopen(strFilename.c_str(),"rb")) == NULL)
	{
		pos = -1;
	}
	else
	{
		fseek(stream,0,SEEK_END);
# ifdef WIN32
		fgetpos(stream,&pos);
# else
		pos = ftello(stream);
# endif
		fclose(stream);
	}
	return pos;
}

bool Confirm(string strMessage)
{
	bool bReturn = false;
	string strIn;
	cout << strMessage << "(y/N):";
	cin >> strIn;
	if(strIn == "y")
		bReturn = true;
	return bReturn;
}




